import requests

base_url = 'https://www.baidu.com/'
response = requests.get(base_url)

print(response.text)

response.encoding = 'utf-8'   # 设置响应内容编码格式
print(response.text)


base_url = 'https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png'
response = requests.get(base_url)

print(response.content)   # 获取二进制数据

with open('baidu_logo.png', 'wb') as file:
    file.write(response.content)                # 将二进制数据写入文件
